package com.cskaoyan.demo3.servlet;

import com.cskaoyan.demo3.bean.BaseRespVo;
import com.cskaoyan.demo3.bean.MarketUser;
import com.cskaoyan.demo3.bean.PageInfo;
import com.cskaoyan.demo3.service.AdminUerService;
import com.cskaoyan.demo3.service.AdminUerServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

/**
 * @Description：
 * @Author：BLUEBLANK
 * @Date：2024/4/9 19:47
 */

@WebServlet("/admin/user/*")
public class AdminUserServlet extends CommonServlet {
    AdminUerService adminUerService = new AdminUerServiceImpl();

    public BaseRespVo list(HttpServletRequest request, HttpServletResponse response) throws InvocationTargetException, IllegalAccessException {
        // 获取请求参数
        Map<String, String[]> parameterMap = request.getParameterMap();
        // 获取分页信息
        PageInfo pageInfo = PageInfo.transfor(parameterMap);

        // 封装用户信息
        MarketUser marketUser = new MarketUser();
        BeanUtils.copyProperties(marketUser, parameterMap);

        // 查询用户列表
        List<MarketUser> list= adminUerService.query(marketUser, pageInfo);


        return BaseRespVo.ok(list);

    }
}
